package com.siwei.mes.entity.laboratory;


import com.siwei.mes.common.util.NullUtils;
import com.siwei.mes.entity.sync.erp.ErpCustomer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

@Data
@Table(name = "Custom_Info")
@Accessors(chain = true)
@ApiModel(value = "Custom_Info", description = "上海协会客户信息实体")
public class CustomData {
    @Transient
    @ApiModelProperty(value = "协会客户id")
    private String custId;

    @Transient
    @ApiModelProperty(value = "客户编号")
    private String custNo;

    @Transient
    @ApiModelProperty(value = "客户名称")
    private String custUnitName;

    @Transient
    @ApiModelProperty(value = "客户地址")
    private String custUnitAddress;

    @Transient
    @ApiModelProperty(value = "法定代表人")
    private String custLegalRepresentative;

    @Transient
    @ApiModelProperty(value = "法定委托人")
    private String custConsigner;

    @Transient
    @ApiModelProperty(value = "联系人")
    private String custLinkMan;

    @Transient
    @ApiModelProperty(value = "联系电话")
    private String custLinkPhone;

    @Transient
    @ApiModelProperty(value = "创建时间")
    private Date custCreateDate;

    /**
     * 组装成协会软件的实体
     *
     * @param erpCustomer
     * @param custId
     * @return
     */
    public static CustomData payloadInfo(ErpCustomer erpCustomer, String custId) {
        CustomData customData = new CustomData();
        customData.setCustNo(NullUtils.ifNull(erpCustomer.getCustomerNo()));
        customData.setCustUnitName(NullUtils.ifNull(erpCustomer.getCustomerName()));
        customData.setCustUnitAddress(NullUtils.ifNull(erpCustomer.getCustomerAddress()));
        customData.setCustLegalRepresentative(NullUtils.ifNull(erpCustomer.getLegalPerson()));
        customData.setCustConsigner(NullUtils.ifNull(erpCustomer.getConsigner()));
        customData.setCustLinkMan(NullUtils.ifNull(erpCustomer.getLinkman()));
        customData.setCustLinkPhone(NullUtils.ifNull(erpCustomer.getLinkPhone()));
        customData.setCustCreateDate(NullUtils.ifNullDate(erpCustomer.getCreateTime()));
        customData.setCustId(NullUtils.ifNull(custId));
        return customData;
    }
}
